<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.c1
{
float:left;
}
.c2
{
float:right;
}
.c1,.c2
{
width: 350px;
padding:5px;
color:#000099;
font-family:verdana,arial;
font-size:16px;
}
label input
{
position:relative;
margin-left:10px;
}
#relatorioGeral
{
width:790px;
height:440px;
overflow:auto;
}

.ttopo
{
background:#1c1c1c;
color:#FFFFFF;

}
.ttitulo
{
background:#6c6c6c;
color:#FFFFFF;

}
td
{
padding:0px;
border:0px;
}
.escuro
{
background:#CCCCCC;
}
.claro
{
background:#FFFFFF;
}
#menu 
{
text-align:center;
}
a
{
text-decoration:none;
font:Arial, Helvetica, sans-serif 16px ;
color:black;
margin:3px;
background:#999999;
border:1px solid black;
}
</style>
<script src="config/funcoes.js" language="javascript"></script>
<script language="javascript">
function validar(op)
{
var msg='';
if(document.getElementById('nome').value!="")
	{
	if(document.getElementById('email').value!="")
		{
		if(document.getElementById('login').value!="")
			{
			if(document.getElementById('senha1').value!="" && (document.getElementById('senha1').value==document.getElementById('senha2').value))
				{
				if(op=='salvar')
					doPost('frm_conf', 'salvarUsuario');
				else
					doPost('frm_conf', 'alterarUsuario');	
				}
			else
				{	
				msg+="Digite uma senha válida \n\r";
				}
			}
		else
			{	
			msg+="Digite um Login válido\n\r";
			}
		}
	else
		{	
		msg+="Digite um Email válido \n\r";
		}
	}
else
	{	
	msg+="Digite o nome \n\r";
	}
	
if(msg!="")
	alert(msg);
}
</script>
<?php
//ini_set('display_errors', 1);
include("admin/con_dbinterface.php");
if($_GET['codigo'])
{
	$sql = "select *
from historico.usuarios where co_usuario=".$_GET['codigo'];
if($res1=pg_query($sql))
	{
	$registro=pg_fetch_array($res1);
	}
}
$sql = "select historico.usuarios.*
from historico.usuarios limit 50 offset 0 ";

if($res=pg_query($sql))
{
$total=pg_num_rows($res);
?>

<div id="relatorioGeral">
<div id="centro">
<table width="100%">
<tr>
<td colspan="7">
  <form action="config/funcoes.php" name="frm_conf" id="frm_conf" method="post" enctype="application/x-www-form-urlencoded" onsubmit="validar()"><input type="hidden" id="action" name="action" /><fieldset>
<label style="display:none"><span>Codigo:</span><input type="text" name="codigo"  id="codigo" size="35" value="<?php echo $registro['co_usuario']; ?>"></label>
<label class="c1"><span>Nome:</span><input type="text" name="nome"  id="nome" size="35" value="<?php echo $registro['nome']; ?>"></label>
<label class="c2"><span>Telefone:</span><input type="text" name="fone" id="fone" size="18" value="<?php echo $registro['fone']; ?>"></label>
<label class="c1"><span>Email:</span><input type="text" name="email" id="email" size="35" value="<?php echo $registro['email']; ?>"></label>
<label class="c2"><span>login:</span><input type="text" name="login" id="login" size="15" value="<?php echo $registro['usuario']; ?>"></label>
<label class="c1"><span>Senha:</span><input type="password" name="senha1"  id="senha1"size="15" value="<?php echo $registro['senha']; ?>"></label>
<label class="c2"><span>Confirmar Senha:</span><input type="password" name="senha2" id="senha2" size="15" value="<?php echo $registro['senha']; ?>"></label>
<input type="button" value="Salvar" <?php if(!$res1) { ?> onclick="javascript:validar('salvar')" <?php } else { ?> onclick="javascript:validar('alterar')" <?php }  ?> style="clear:both"/>
<input type="button" onclick="window.location.href='cadastro_usuarios.php'" value="Cancelar">
</fieldset>
</form></td>
</tr>
 <div id="fixaTopo">
<tr class="ttopo">
<td>CODIGO</td>
<td>USUARIO</td>
<td>TELEFONE</td>
<td>EMAIL</td>
<td>LOGIN</td>
<td></td>
</tr>
</div>
<?php 
$regAnterior="00";
$classe="escuro";
while($registro=pg_fetch_array($res))
{
 ?>
<tr class="ttitulo">
<td><?php echo $registro['co_usuario']; ?></td>
<td><?php echo $registro['nome']; ?></td>
<td><?php echo $registro['fone']; ?></td>
<td><?php echo $registro['email']; ?></td>
<td><?php echo $registro['usuario'] ;?></td>
<td><?php echo "<a href='cadastro_usuarios.php?codigo=$registro[co_usuario]'>Editar</a>" ;?></td>
</tr>
<?php
if($classe=="escuro")
	$classe="claro";
else
	$classe="escuro";	
 } ?>
</table>
</div>
<div id="rodape">

</div>

</div>


<?php
}
else
echo "Erro - SQL error";
?>
